home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / percnt.zip / CTRLINIT.PAS < prev    next >
Pascal/Delphi Source File  |  1991-11-10  |  2KB  |  78 lines

  1. {***************************************************************************
  2.  
  3.     NoMan Custom Control Library            $Version$
  4.     Initialization Code Unit
  5.     $Author$        $Date$
  6.  
  7.         Copyright 1991 Anthony M. Vitabile
  8.  
  9.     Unit Description
  10.  
  11.     This Turbo Pascal for Windows unit contains the code used to
  12.     implement the initialization code for a library implementing a
  13.     new kind of control window for use in dialog boxes.  The code
  14.     in this module defines the initialization code for the library.
  15.  
  16.     The library uses straight Windows calls and does NOT use Object-
  17.     Windows.  This is to allow the control to be used by ANY Windows
  18.     program.
  19.  
  20.     This code is adapted from the code that appeared in the July,
  21.     1990 issue of Microsoft Systems Journal article, "Extending the
  22.     Windows 3.0 Interface with Installable Custom Controls" by Kevin
  23.     P. Welch.  The code has been customized for use with Resource
  24.         Workshop.
  25.  
  26. ***************************************************************************}
  27.  
  28. {$C Preload Discardable}
  29. Unit CtrlInit;
  30. Interface
  31.  
  32.   procedure CtrlLibInit;
  33.   procedure LibExit;
  34.  
  35. Implementation
  36.   Uses CtrlCommonDefs, WndFnPercentCtrl, WinTypes, WinProcs;
  37.  
  38.   var
  39.     SaveExit:  Pointer;
  40.  
  41.   procedure CtrlLibInit;
  42.     var
  43.       OK:  boolean;
  44.       WC:  TWndClass;
  45.  
  46.     begin    { CtrlLibInit }
  47.                { Register Percent Control Class first }
  48.       WC.style           := Pct_ClassStyle;
  49.       WC.lpfnWndProc   := @PercentCtrlWndFn;
  50.       WC.cbClsExtra    := Pct_ClassExtra;
  51.       WC.cbWndExtra    := Pct_WndExtra;
  52.       WC.hInstance     := HInstance;
  53.       WC.hIcon           := 0;
  54.       WC.hCursor       := 0;
  55.       WC.hbrBackground := 0;
  56.       WC.lpszMenuName  := nil;
  57.       WC.lpszClassName := Pct_Name;
  58.  
  59.       OK := RegisterClass(WC);
  60.  
  61.       if not OK
  62.        then ExitCode := 0        { Cause the DLL to unload itself! }
  63.        else                { Install our exit handler }
  64.     begin
  65.      SaveExit := ExitProc;        { Save old exit procedure pointer }
  66.      ExitProc := @LibExit        { Install LibExit exit procedure }
  67.     end
  68.     end     { PercentCtrlInit };
  69.  
  70. {$S-}
  71.   procedure LibExit;
  72.     begin    { LibExit }
  73.       UnregisterClass(Pct_Name, HInstance);
  74.       ExitProc := SaveExit
  75.     end     { LibExit };
  76.  
  77.   end.
  78.